//
//  YFGuideViewcontroller.m
//  SquashSpark
//
//  Created by Coollang on 2017/12/21.
//  Copyright © 2017年 Coollang-YF. All rights reserved.
//

#import "YFGuideViewcontroller.h"

@interface YFGuideViewcontroller ()

@property (weak, nonatomic) IBOutlet UIView *bottomView;
@property (weak, nonatomic) IBOutlet UIButton *signUpButton;
@property (weak, nonatomic) IBOutlet UIButton *signInButton;
@property (weak, nonatomic) IBOutlet UIImageView *guideImageView;
@property (weak, nonatomic) IBOutlet UILabel *bigTitleLabel;
@property (weak, nonatomic) IBOutlet UILabel *smallTextLabel;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *imageTopCon;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *imageBottomCon;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottomViewHeightCon;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *textWidthCon;

@end

@implementation YFGuideViewcontroller

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self adaptiveScreen];
    [UIView animateWithDuration:0.35 animations:^{
        [self.bottomView layoutIfNeeded];
        [self.guideImageView layoutIfNeeded];
        [self.bigTitleLabel layoutIfNeeded];
        [self.smallTextLabel layoutIfNeeded];
    }];
    [self updateUIWithGuideStatePage:self.gudieStatePage];
}

- (void)updateUIWithGuideStatePage:(kGuideStatePage)statePage {
    NSString *iamgeName = @"guide_analyze";
    NSString *titleText = @"MOTION ANALYSIS";
    NSString *smallText = @"Record the details of the movement of each swing and found that training every day,the moment of progress,so that data to help you improve training results";
    switch (statePage) {
        case kGuideMotionAnalyPage:
            break;
        case kGuideReal3DPage:{
            iamgeName = @"guide_3D";
            titleText = @"REAL 3D MOTION SIMULATION";
            smallText = @"3D motion trajectory reduction, real-time training and forecasting,powerful action data entry capabilities to facilitate the establishment of personal training database";
        }
            break;
        case kGuideVideoPage:{
            iamgeName = @"guide_coachVideo";
            titleText = @"TRAINING VIDEO";
            smallText = @"Top athletes demonstrate their own unique skills,personalized video teaching more vivid,more free star coaching video stay tuned for follow-up";
        }
            break;
        case kGuideCluePage:{
            iamgeName = @"guide_club";
            titleText = @"JOIN THE CLUB";
            smallText = @"Develop your weekly plan,view weekly sports reports,get coaching advice, experience smart squash with more club members";
        }
            break;
        default:
            break;
    }
    self.bigTitleLabel.text = titleText;
    self.smallTextLabel.text = smallText;
    self.guideImageView.image = [UIImage imageNamed:iamgeName];
}


- (IBAction)signUpButtonClick:(id)sender {
    if ([self.delegate respondsToSelector:@selector(signUpACtionWithguideController:andGuideStatePage:)]) {
        [self.delegate signUpACtionWithguideController:self andGuideStatePage:self.gudieStatePage];
    }
}

- (IBAction)signInButtonCllick:(id)sender {
    if ([self.delegate respondsToSelector:@selector(signInACtionWithguideController:andGuideStatePage:)]) {
        [self.delegate signInACtionWithguideController:self andGuideStatePage:self.gudieStatePage];
    }
}

//屏幕适配
- (void)adaptiveScreen {
    CGFloat screenWidth = MIN(kYFScreenWidth, kYFScreenHeight);
    CGFloat scale = screenWidth/375.0;
    self.imageTopCon.constant = self.imageTopCon.constant * scale;
    self.imageTopCon.constant =  self.imageTopCon.constant * scale;
    self.imageBottomCon.constant = self.imageBottomCon.constant * scale;
    self.textWidthCon.constant = self.textWidthCon.constant * scale;
   // self.bottomViewHeightCon.constant = self.bottomViewHeightCon.constant * scale;
    self.bottomViewHeightCon = 0;
    if (IS_IPAD) {
        self.bigTitleLabel.font = kOpenSansFont(OpenSansRegular, 32);
        self.smallTextLabel.font = kOpenSansFont(OpenSansRegular, 22);
        self.signInButton.titleLabel.font = kOpenSansFont(OpenSansExtraBold, 24);
        self.signUpButton.titleLabel.font = kOpenSansFont(OpenSansExtraBold, 24);
    }else {
        self.bigTitleLabel.font = kOpenSansFont(OpenSansRegular, 16);
        self.smallTextLabel.font = kOpenSansFont(OpenSansRegular, 12);
        self.signInButton.titleLabel.font = kOpenSansFont(OpenSansExtraBold, 13);
        self.signUpButton.titleLabel.font = kOpenSansFont(OpenSansExtraBold, 13);
    }
}
@end
